<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<script type="text/javascript">
    $(function() {
        mallEtcCardRuleModule.init();
    });
    var mallEtcCardRuleModule = (function(){

        /*初始化时间查询*/
        var initDate = function(){
            $("input[name='createtime_begin']").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});});
            $("input[name='createtime_end']").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});});
        }

        var module = {
            init :function(){
                initDate();
            },
            saveview : function(){
                addOneTab("添加ETC卡", "mallEtcCardRuleController.do?saveview");
            }
        };
        return module;
    })();
</script>
<div class="easyui-layout" fit="true">
    <div region="center" style="padding:0px;border:0px">
        <t:datagrid name="mallEtcCardRuleList" title="商城ETC卡卡号管理" actionUrl="mallEtcCardRuleController.do?datagrid" idField="id" fit="true" queryMode="group" onClick="showDtn">
            <t:dgCol title="编号" field="id" hidden="true"></t:dgCol>
            <t:dgCol title="店铺名称" field="shop.shopname"  query="true"  width="120"></t:dgCol>
            <t:dgCol title="商品名称" field="product.productname"   width="120"></t:dgCol>
            <t:dgCol title="ETC供应商" field="etcSupplier.suppliername"   width="120"></t:dgCol>
            <t:dgCol title="ETC卡号" field="cardno" query="true"   width="120"></t:dgCol>
            <t:dgCol title="创建人" field="createuserid"   width="120"></t:dgCol>
            <t:dgCol title="车牌号" field="etcUser.carno"   width="120" query="true"></t:dgCol>
            <t:dgCol title="用户名" field="etcUser.lhbUser.userName"   width="120"></t:dgCol>
            <t:dgCol title="用户姓名" field="etcUser.lhbUser.fullname"   width="120"></t:dgCol>
            <t:dgCol title="创建时间" field="createtime" formatter="yyyy-MM-dd hh:mm:ss" query="true" queryMode="group"  width="120"></t:dgCol>
            <t:dgCol title="状态" replace="未使用_0,已分配待审核_1,已使用_2" field="state"  query="true"  width="120"></t:dgCol>
            <t:dgCol title="操作" field="opt" width="100"></t:dgCol>
            <t:dgDelOpt title="删除" url="mallEtcCardRuleController.do?del&id={id}" exp="state#ne#2"/>
            <t:dgToolBar title="录入" icon="icon-add" funname="mallEtcCardRuleModule.saveview"></t:dgToolBar>
            <t:dgToolBar title="关联用户" icon="icon-add" funname="linkUser" ></t:dgToolBar>
            <%--   <t:dgToolBar title="编辑" icon="icon-edit" url="mallEtcCardRuleController.do?addorupdate" funname="update"></t:dgToolBar>
               <t:dgToolBar title="查看" icon="icon-search" url="mallEtcCardRuleController.do?addorupdate" funname="detail"></t:dgToolBar>--%>
        </t:datagrid>
    </div>
</div>
<script type="text/javascript">
    //关联用户
    function linkUser(){
        var rowsData = $('#mallEtcCardRuleList').datagrid('getSelections');
        if (!rowsData || rowsData.length==0) {
            tip('请选择 编辑项目');
            return "";
        }
        if (rowsData.length>1) {
            tip('请选择一个项目编辑');
            return "";
        }
        var cardno = rowsData[0].cardno;
        var addUrl =  "mallEtcUserController.do?addorupdate&cardno="+cardno;
        //addOneTab("关联用户",addUrl);
        add('关联用户',addUrl,'mallEtcCardRuleList',790,300);
    }
    function showDtn(rowIndex,rowData){
        //卡号状态 0 未使用时支持关联用户
        var state = rowData.state;
        if(state=='0'){
            $("a[onclick ^= 'linkUser']").css("display","inline");
        }else{
            $("a[onclick ^= 'linkUser']").css("display","none");
        }
    }
</script>